<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        反转字符串<br>

        var str = 'abcdefg'<br>

        // 要求结果<br>
        // gfedcba<br>
    </div>
    <script>
        function strReverse ( str ) {
            var arr = str.split("");
            return arr.reverse().join("");
        }
        var str = 'abcdefg' ; 
        console.log(strReverse(str));
    </script>
</body>
</html>